﻿#include "AutoPatcherAdmin.AMain.h"
#include "Settings.h"

namespace AutoPatcherAdmin
{

const std::string AMain::PatchFileName = R"(PList.gz)";

    AMain::AMain()
    {
        InitializeComponent();

        ClientTextBox->Text = Settings::Client;
        HostTextBox->Text = Settings::Host;
        LoginTextBox->Text = Settings::Login;
        PasswordTextBox->Text = Settings::Password;
        AllowCleanCheckBox->Checked = Settings::AllowCleanUp;
    }

    void AMain::CompleteDownload()
    {
        FileLabel->Text = "Complete...";
        SizeLabel->Text = "Complete...";
        SpeedLabel->Text = "Complete...";
        ActionLabel->Text = "Complete...";

        progressBar1->Value = 100;
        progressBar2->Value = 100;

        DownloadExistingButton->Enabled = true;

        Completed = true;
    }

    void AMain::CleanUp()
    {
        if (!Settings::AllowCleanUp)
        {
            return;
        }

        for (int i = 0; i < OldList.size(); i++)
        {
            if (NeedFile(OldList[i]->FileName))
            {
                continue;
            }

            auto compressed = OldList[i]->Length != OldList[i]->Compressed;
            try
            {
                Uri tempVar(Settings::Host + OldList[i]->FileName + (compressed ? ".gz" : ""));
                FtpWebRequest *request = static_cast<FtpWebRequest*>(WebRequest::Create(&tempVar));
                request->Credentials = new NetworkCredential(Settings::Login, Settings::Password);
                request->Method = WebRequestMethods::Ftp::DeleteFile;
                FtpWebResponse *response = static_cast<FtpWebResponse*>(request->GetResponse());
                response->Close();
            }
            catch (...)
            {

            }
        }

    }

    bool AMain::NeedFile(const std::string &fileName)
    {
        for (int i = 0; i < NewList.size(); i++)
        {
            if (StringHelper::endsWith(fileName, NewList[i]->FileName) && !InExcludeList(NewList[i]->FileName))
            {
                return true;
            }
        }

        return false;
    }

    void AMain::GetOldFileList()
    {
        OldList = std::vector<FileInformation*>();

        std::vector<unsigned char> data = Download(PatchFileName);

        if (!data.empty())
        {
//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using MemoryStream stream = new MemoryStream(data);
            {
                MemoryStream stream = MemoryStream(data);;
//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using BinaryReader reader = new BinaryReader(stream);
                {
                    BinaryReader reader = BinaryReader(stream);;
    
                    int count = reader.ReadInt32();
    
                    for (int i = 0; i < count; i++)
                    {
                        FileInformation tempVar(reader);
                        OldList.push_back(&tempVar);
                    }
                }
            }
        }
    }

    std::vector<unsigned char> AMain::CreateNew()
    {
//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using MemoryStream stream = new MemoryStream();
        {
            MemoryStream stream = MemoryStream();;
//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using BinaryWriter writer = new BinaryWriter(stream);
            {
                BinaryWriter writer = BinaryWriter(stream);;
    
                writer.Write(NewList.size());
                for (int i = 0; i < NewList.size(); i++)
                {
                    NewList[i]->Save(writer);
                }
    
                return stream.ToArray();
            }
        }
    }

    void AMain::GetNewFileList()
    {
        NewList = std::vector<FileInformation*>();

        std::vector<std::string> files = Directory::GetFiles(Settings::Client, "*.*",SearchOption::AllDirectories);

        for (int i = 0; i < files.size(); i++)
        {
            NewList.push_back(GetFileInformation(files[i]));
        }
    }

    bool AMain::InExcludeList(const std::string &fileName)
    {
        for (auto item : ExcludeList)
        {
            if (StringHelper::endsWith(fileName, item))
            {
                return true;
            }
        }

        return false;
    }

    void AMain::FixFilenameExtensions()
    {
        for (int i = 0; i < OldList.size(); i++)
        {
            FileInformation *old = OldList[i];

            try
            {
                ActionLabel->Text = old->FileName;
                Refresh();

                if (old->Compressed == old->Length)
                {
                    //exists, but not compressed, lets rename it

                    Uri tempVar(Settings::Host + "/" + old->FileName + ".gz");
                    FtpWebRequest *request = static_cast<FtpWebRequest*>(WebRequest::Create(&tempVar));
                    request->Credentials = new NetworkCredential(Settings::Login, Settings::Password);
                    request->Method = WebRequestMethods::Ftp::Rename;
                    request->RenameTo = FileSystem::getFileName(old->FileName);

                    FtpWebResponse *ftpResponse = static_cast<FtpWebResponse*>(request->GetResponse());
                    ftpResponse->Close();
                }
                else
                {
                    //exists, but its compressed and ends with .gz, so its correct
                }
            }
            catch (const WebException &ex)
            {
                FtpWebResponse *response = static_cast<FtpWebResponse*>(ex->Response);
                response->Close();
            }
        }
    }

    bool AMain::NeedUpdate(FileInformation *info)
    {
        for (int i = 0; i < OldList.size(); i++)
        {
            FileInformation *old = OldList[i];
            if (old->FileName != info->FileName)
            {
                continue;
            }

            if (old->Length != info->Length)
            {
                return true;
            }
            if (old->Creation != info->Creation)
            {
                return true;
            }

            return false;
        }
        return true;
    }

    DateTime AMain::TrimMilliseconds(DateTime dt)
    {
        return DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, dt.Second, 0, dt.Kind);
    }

    FileInformation *AMain::GetFileInformation(const std::string &fileName)
    {
        if (!FileSystem::fileExists(fileName))
        {
            return nullptr;
        }

        FileInfo *info = new FileInfo(fileName);

        FileInformation *file = new FileInformation();
//C# TO C++ CONVERTER TODO TASK: There is no C++ equivalent to the .NET String 'Remove' method unless assigning to the string instance:
        file->FileName = fileName.Remove(0, Settings::Client.length());
        file->Length = static_cast<int>(info->Length);
        file->Creation = info->LastWriteTime;

        if (file->FileName == "AutoPatcher.exe")
        {
            file->FileName = "AutoPatcher.gz";
        }

//C# TO C++ CONVERTER TODO TASK: A 'delete file' statement was not added since file was used in a 'return' or 'throw' statement.
        delete info;
        return file;
    }

    std::vector<unsigned char> AMain::Download(const std::string &fileName)
    {
        try
        {
//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using (WebClient client = new WebClient())
            {
                WebClient client = WebClient();
                client.Credentials = new NetworkCredential(Settings::Login, Settings::Password);
                return client.DownloadData(Settings::Host + "/" + fileName);
            }
        }
        catch (...)
        {
            return std::vector<unsigned char>();
        }
    }

    void AMain::Download(FileInformation *info)
    {
        std::string fileName = StringHelper::replace(info->FileName, R"(\)", "/");

        if (fileName != "PList.gz" && (info->Compressed != info->Length || info->Compressed == 0))
        {
            fileName += ".gz";
        }

        try
        {
//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using (WebClient client = new WebClient())
            {
                WebClient client = WebClient();
                client.DownloadProgressChanged += [&] (o, e)
                {
                    _currentBytes = e::BytesReceived;
    
                    int value = static_cast<int>(100 * _currentBytes / _currentFile->Length);
                    progressBar2->Value = value > progressBar2->Maximum ? progressBar2->Maximum : value;
    
                    FileLabel->Text = fileName;
                    SizeLabel->Text = StringHelper::formatSimple("{0} KB / {1} KB", _currentBytes / 1024, _currentFile->Length / 1024);
                    SpeedLabel->Text = (_currentBytes / 1024.0F / _stopwatch->Elapsed.TotalSeconds).ToString("#,##0.##") + "KB/s";
                };
                client.DownloadDataCompleted += [&] (o, e)
                {
                    if (e::Error != nullptr)
                    {
                        File::AppendAllText(R"(.\Error.txt)", StringHelper::formatSimple("[{0}] {1}{2}", DateTime::Now, info->FileName + " could not be downloaded. (" + e::Error->Message + ")", "\r\n"));
                    }
                    else
                    {
                        _currentCount++;
                        _completedBytes += _currentBytes;
                        _currentBytes = 0;
                        _stopwatch->Stop();
    
                        std::vector<unsigned char> raw = e::Result;
    
                        if (info->Compressed > 0 && info->Compressed != info->Length)
                        {
                            raw = Decompress(e::Result);
                        }
    
                        if (!FileSystem::directoryExists(Settings::Client + FileSystem::getDirectoryName(info->FileName)))
                        {
                            FileSystem::createDirectory(Settings::Client + FileSystem::getDirectoryName(info->FileName));
                        }
    
                        File::WriteAllBytes(Settings::Client + info->FileName, raw);
                        File::SetLastWriteTime(Settings::Client + info->FileName, info->Creation);
                    }
                    BeginDownload();
                };

                client.Credentials = new NetworkCredential(Settings::Login, Settings::Password);

                progressBar1->Value = static_cast<int>(_completedBytes * 100 / _totalBytes) > 100 ? 100 : static_cast<int>(_completedBytes * 100 / _totalBytes);

                _stopwatch = Stopwatch::StartNew();
                Uri tempVar(Settings::Host + fileName);
                client.DownloadDataAsync(&tempVar);
            }
        }
        catch (...)
        {
            MessageBox::Show(StringHelper::formatSimple("Failed to download file: {0}", fileName));
        }
    }

    void AMain::BeginDownload()
    {
        if (DownloadList.empty())
        {
            return;
        }

        if (DownloadList.empty())
        {
            DownloadList = std::deque<FileInformation*>();
            _currentFile = nullptr;
            CompleteDownload();
            DownloadExistingButton->Enabled = true;

            CleanUp();
            return;
        }

        ActionLabel->Text = std::string::Format("Downloading... Files: {0}, Total Size: {1:#,##0}MB (Uncompressed)", DownloadList.size(), (_totalBytes - _completedBytes) / 1048576);

        progressBar1->Value = static_cast<int>(_completedBytes * 100 / _totalBytes) > 100 ? 100 : static_cast<int>(_completedBytes * 100 / _totalBytes);

        _currentFile = DownloadList.pop_front();

        Download(_currentFile);
    }

    void AMain::Upload(FileInformation *info, std::vector<unsigned char> &raw, bool retry)
    {
        std::string fileName = StringHelper::replace(info->FileName, R"(\)", "/");

//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using (WebClient client = new WebClient())
        {
            WebClient client = WebClient();
            client.Credentials = new NetworkCredential(Settings::Login, Settings::Password);

            std::vector<unsigned char> data = (!retry || !Settings::CompressFiles || fileName == "PList.gz" || fileName == "AutoPatcher.gz") ? raw : Compress(raw);
            info->Compressed = data.size();

            if (fileName != "AutoPatcher.gz" && fileName != "PList.gz" && Settings::CompressFiles)
            {
                fileName += ".gz";
            }

            client.UploadProgressChanged += [&] (o, e)
            {
                    int value = static_cast<int>(100 * e::BytesSent / e::TotalBytesToSend);
                    progressBar2->Value = value > progressBar2->Maximum ? progressBar2->Maximum : value;
    
                    FileLabel->Text = fileName;
                    SizeLabel->Text = StringHelper::formatSimple("{0} KB / {1} KB", e::BytesSent / 1024, e::TotalBytesToSend / 1024);
                    SpeedLabel->Text = (static_cast<double>(e::BytesSent) / 1024 / _stopwatch->Elapsed.TotalSeconds).ToString("0.##") + " KB/s";
            };

            client.UploadDataCompleted += [&] (o, e)
            {
                    _completedBytes += info->Length;
    
                    if (e::Error != nullptr && retry)
                    {
                        CheckDirectory(FileSystem::getDirectoryName(fileName));
                        Upload(info, data, false);
                        return;
                    }
    
                    if (info->FileName == PatchFileName)
                    {
                        FileLabel->Text = "Complete...";
                        SizeLabel->Text = "Complete...";
                        SpeedLabel->Text = "Complete...";
                        return;
                    }
    
                    progressBar1->Value = static_cast<int>(_completedBytes * 100 / _totalBytes) > 100 ? 100 : static_cast<int>(_completedBytes * 100 / _totalBytes);
                    BeginUpload();
            };

            _stopwatch = Stopwatch::StartNew();

            Uri tempVar(Settings::Host + fileName);
            client.UploadDataAsync(&tempVar, data);
        }
    }

    void AMain::BeginUpload()
    {
        if (UploadList.empty())
        {
            return;
        }

        if (UploadList.empty())
        {
            CleanUp();

            FileInformation *tempVar = new FileInformation(), *CreateNew;
            tempVar->FileName = PatchFileName;
            Upload(tempVar, CreateNew());
            UploadList = std::deque<FileInformation*>();
            ActionLabel->Text = std::string::Format("Complete...");
            ProcessButton->Enabled = true;

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
            return;
        }

        ActionLabel->Text = std::string::Format("Uploading... Files: {0}, Total Size: {1:#,##0}MB (Uncompressed)", UploadList.size(), (_totalBytes - _completedBytes) / 1048576);

        progressBar1->Value = static_cast<int>(_completedBytes * 100 / _totalBytes) > 100 ? 100 : static_cast<int>(_completedBytes * 100 / _totalBytes);

        FileInformation *info = UploadList.pop_front();
        Upload(info, File::ReadAllBytes(Settings::Client + (info->FileName == "AutoPatcher.gz" ? "AutoPatcher.exe" : info->FileName)));
    }

    void AMain::CheckDirectory(const std::string &directory)
    {
        std::string Directory = "";
        std::vector<char> splitChar = {'\\'};
        std::vector<std::string> DirectoryList = directory.Split(splitChar);

        for (auto directoryCheck : DirectoryList)
        {
            Directory += "\\" + directoryCheck;

            try
            {
                if (Directory.empty())
                {
                    return;
                }

                FtpWebRequest *request = static_cast<FtpWebRequest*>(WebRequest::Create(Settings::Host + Directory + "/"));
                request->Credentials = new NetworkCredential(Settings::Login, Settings::Password);
                request->Method = WebRequestMethods::Ftp::MakeDirectory;

                request->UsePassive = true;
                request->UseBinary = true;
                request->KeepAlive = false;
                FtpWebResponse *response = static_cast<FtpWebResponse*>(request->GetResponse());
                Stream *ftpStream = response->GetResponseStream();

                if (ftpStream != nullptr)
                {
                    ftpStream->Close();
                }
                response->Close();

            }
            catch (const WebException &ex)
            {
                FtpWebResponse *response = static_cast<FtpWebResponse*>(ex->Response);
                response->Close();
            }
        }
    }

    std::vector<unsigned char> AMain::Decompress(std::vector<unsigned char> &raw)
    {
//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using (GZipStream gStream = new GZipStream(new MemoryStream(raw), CompressionMode.Decompress))
        {
            MemoryStream tempVar(raw);
            GZipStream gStream = GZipStream(&tempVar, CompressionMode::Decompress);
            constexpr int size = 4096; //4kb
            std::vector<unsigned char> buffer(size);
//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using (MemoryStream mStream = new MemoryStream())
            {
                MemoryStream mStream = MemoryStream();
                int count;
                do
                {
                    count = gStream.Read(buffer, 0, size);
                    if (count > 0)
                    {
                        mStream.Write(buffer, 0, count);
                    }
                } while (count > 0);
                return mStream.ToArray();
            }
        }
    }

    std::vector<unsigned char> AMain::Compress(std::vector<unsigned char> &raw)
    {
//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using (MemoryStream mStream = new MemoryStream())
        {
            MemoryStream mStream = MemoryStream();
//C# TO C++ CONVERTER NOTE: The following 'using' block is replaced by its C++ equivalent:
//ORIGINAL LINE: using (GZipStream gStream = new GZipStream(mStream, CompressionMode.Compress, true))
            {
                GZipStream gStream = GZipStream(mStream, CompressionMode::Compress, true);
                gStream.Write(raw, 0, raw.size());
            }
            return mStream.ToArray();
        }
    }

    void AMain::ListButton_Click(std::any sender, EventArgs *e)
    {
        Settings::Client = ClientTextBox->Text;
        Settings::Host = HostTextBox->Text;
        Settings::Login = LoginTextBox->Text;
        Settings::Password = PasswordTextBox->Text;

        GetOldFileList();
        GetNewFileList();

        for (int i = 0; i < NewList.size(); i++)
        {
            FileInformation *info = NewList[i];
            for (int o = 0; o < OldList.size(); o++)
            {
                if (OldList[o]->FileName != info->FileName)
                {
                    continue;
                }

                NewList[i]->Compressed = OldList[o]->Compressed;
                break;
            }

            if (info->Compressed == 0)
            {
                //We've uploaded a new file which is unknown to the existing PList (or no PList available). Assume this file was uploaded uncompressed and set to file length.
                info->Compressed = info->Length;
            }
        }

        FileInformation *tempVar = new FileInformation(), *CreateNew;
        tempVar->FileName = PatchFileName;
        Upload(tempVar, CreateNew());

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
    }

    void AMain::ProcessButton_Click(std::any sender, EventArgs *e)
    {
        try
        {
            ProcessButton->Enabled = false;
            Settings::Client = ClientTextBox->Text;
            Settings::Host = HostTextBox->Text;
            Settings::Login = LoginTextBox->Text;
            Settings::Password = PasswordTextBox->Text;
            Settings::AllowCleanUp = AllowCleanCheckBox->Checked;

            UploadList = std::deque<FileInformation*>();

            GetOldFileList();

            ActionLabel->Text = "Checking Files...";
            Refresh();

            GetNewFileList();

            for (int i = 0; i < NewList.size(); i++)
            {
                FileInformation *info = NewList[i];

                if (InExcludeList(info->FileName))
                {
                    continue;
                }

                if (NeedUpdate(info))
                {
                    UploadList.push_back(info);
                    _totalBytes += info->Length;
                }
                else
                {
                    for (int o = 0; o < OldList.size(); o++)
                    {
                        if (OldList[o]->FileName != info->FileName)
                        {
                            continue;
                        }
                        NewList[i] = OldList[o];
                        break;
                    }
                }
            }

            BeginUpload();

        }
        catch (const std::runtime_error &ex)
        {
            MessageBox::Show(ex.what());
            ActionLabel->Text = "Error...";
        }

    }

    void AMain::btnFixGZ_Click(std::any sender, EventArgs *e)
    {
        btnFixGZ->Enabled = false;

        Settings::Client = ClientTextBox->Text;
        Settings::Host = HostTextBox->Text;
        Settings::Login = LoginTextBox->Text;
        Settings::Password = PasswordTextBox->Text;

        GetOldFileList();
        GetNewFileList();

        for (int i = 0; i < NewList.size(); i++)
        {
            FileInformation *info = NewList[i];
            for (int o = 0; o < OldList.size(); o++)
            {
                if (OldList[o]->FileName != info->FileName)
                {
                    continue;
                }
                NewList[i]->Compressed = OldList[o]->Length;
                break;
            }
        }

        FileInformation *tempVar = new FileInformation(), *CreateNew;
        tempVar->FileName = PatchFileName;
        Upload(tempVar, CreateNew());

        FixFilenameExtensions();

//C# TO C++ CONVERTER TODO TASK: A 'delete tempVar' statement was not added since tempVar was passed to a method or constructor. Handle memory management manually.
    }

    void AMain::DownloadExistingButton_Click(std::any sender, EventArgs *e)
    {
        DownloadExistingButton->Enabled = false;
        Settings::Client = ClientTextBox->Text;
        Settings::Host = HostTextBox->Text;
        Settings::Login = LoginTextBox->Text;
        Settings::Password = PasswordTextBox->Text;
        Settings::AllowCleanUp = AllowCleanCheckBox->Checked;

        DownloadList = std::deque<FileInformation*>();

        _totalBytes = 0;
        _currentCount = 0;
        _fileCount = 0;

        try
        {
            GetOldFileList();

            if (OldList.size() > 0)
            {
                for (int i = 0; i < OldList.size(); i++)
                {
                    auto old = OldList[i];
                    _currentCount++;

                    FileInformation *info = GetFileInformation(Settings::Client + old->FileName);

                    if (info == nullptr || old->Length != info->Length || old->Creation != info->Creation)
                    {
                        DownloadList.push_back(old);
                        _totalBytes += old->Length;
                    }
                }

                _fileCount = DownloadList.size();
                BeginDownload();
            }
            else
            {
                MessageBox::Show("No existing patch list found");
                CompleteDownload();
                DownloadExistingButton->Enabled = true;
                return;
            }
        }
        catch (const std::runtime_error &ex)
        {
            MessageBox::Show(ex.what(), "Error");
            CompleteDownload();
            DownloadExistingButton->Enabled = true;
        }
    }

    void AMain::SourceLinkLabel_LinkClicked(std::any sender, LinkLabelLinkClickedEventArgs *e)
    {
        SourceLinkLabel->LinkVisited = true;
        Process::Start("http://www.lomcn.org/forum/member.php?141-Jamie-Hello");
    }

    void AMain::AMain_Load(std::any sender, EventArgs *e)
    {

    }

    void AMain::Dispose(bool disposing)
    {
        if (disposing && (components != nullptr))
        {
            components->Dispose();
        }
        System::Windows::Forms::Form::Dispose(disposing);
    }

    void AMain::InitializeComponent()
    {
        this->ClientTextBox = new System::Windows::Forms::TextBox();
        this->label1 = new System::Windows::Forms::Label();
        this->label2 = new System::Windows::Forms::Label();
        this->HostTextBox = new System::Windows::Forms::TextBox();
        this->label3 = new System::Windows::Forms::Label();
        this->LoginTextBox = new System::Windows::Forms::TextBox();
        this->label4 = new System::Windows::Forms::Label();
        this->PasswordTextBox = new System::Windows::Forms::TextBox();
        this->ProcessButton = new System::Windows::Forms::Button();
        this->progressBar1 = new System::Windows::Forms::ProgressBar();
        this->ActionLabel = new System::Windows::Forms::Label();
        this->label5 = new System::Windows::Forms::Label();
        this->progressBar2 = new System::Windows::Forms::ProgressBar();
        this->SpeedLabel = new System::Windows::Forms::Label();
        this->label7 = new System::Windows::Forms::Label();
        this->FileLabel = new System::Windows::Forms::Label();
        this->label8 = new System::Windows::Forms::Label();
        this->SizeLabel = new System::Windows::Forms::Label();
        this->label10 = new System::Windows::Forms::Label();
        this->ListButton = new System::Windows::Forms::Button();
        this->SourceLinkLabel = new System::Windows::Forms::LinkLabel();
        this->AllowCleanCheckBox = new System::Windows::Forms::CheckBox();
        this->DownloadExistingButton = new System::Windows::Forms::Button();
        this->btnFixGZ = new System::Windows::Forms::Button();
        this->SuspendLayout();
        // 
        // ClientTextBox
        // 
        this->ClientTextBox->Location = new System::Drawing::Point(99, 12);
        this->ClientTextBox->Name = "ClientTextBox";
        this->ClientTextBox->Size = new System::Drawing::Size(254, 20);
        this->ClientTextBox->TabIndex = 0;
        // 
        // label1
        // 
        this->label1->AutoSize = true;
        this->label1->Location = new System::Drawing::Point(12, 15);
        this->label1->Name = "label1";
        this->label1->Size = new System::Drawing::Size(81, 13);
        this->label1->TabIndex = 1;
        this->label1->Text = "Client Directory:";
        // 
        // label2
        // 
        this->label2->AutoSize = true;
        this->label2->Location = new System::Drawing::Point(20, 41);
        this->label2->Name = "label2";
        this->label2->Size = new System::Drawing::Size(73, 13);
        this->label2->TabIndex = 4;
        this->label2->Text = "Host Address:";
        // 
        // HostTextBox
        // 
        this->HostTextBox->Location = new System::Drawing::Point(99, 38);
        this->HostTextBox->Name = "HostTextBox";
        this->HostTextBox->Size = new System::Drawing::Size(254, 20);
        this->HostTextBox->TabIndex = 3;
        // 
        // label3
        // 
        this->label3->AutoSize = true;
        this->label3->Location = new System::Drawing::Point(57, 67);
        this->label3->Name = "label3";
        this->label3->Size = new System::Drawing::Size(36, 13);
        this->label3->TabIndex = 6;
        this->label3->Text = "Login:";
        // 
        // LoginTextBox
        // 
        this->LoginTextBox->Location = new System::Drawing::Point(99, 64);
        this->LoginTextBox->Name = "LoginTextBox";
        this->LoginTextBox->Size = new System::Drawing::Size(254, 20);
        this->LoginTextBox->TabIndex = 5;
        // 
        // label4
        // 
        this->label4->AutoSize = true;
        this->label4->Location = new System::Drawing::Point(37, 93);
        this->label4->Name = "label4";
        this->label4->Size = new System::Drawing::Size(56, 13);
        this->label4->TabIndex = 8;
        this->label4->Text = "Password:";
        // 
        // PasswordTextBox
        // 
        this->PasswordTextBox->Location = new System::Drawing::Point(99, 90);
        this->PasswordTextBox->Name = "PasswordTextBox";
        this->PasswordTextBox->Size = new System::Drawing::Size(254, 20);
        this->PasswordTextBox->TabIndex = 7;
        // 
        // ProcessButton
        // 
        this->ProcessButton->Location = new System::Drawing::Point(12, 139);
        this->ProcessButton->Name = "ProcessButton";
        this->ProcessButton->Size = new System::Drawing::Size(75, 23);
        this->ProcessButton->TabIndex = 9;
        this->ProcessButton->Text = "Process";
        this->ProcessButton->UseVisualStyleBackColor = true;
        this->ProcessButton->Click += new System::EventHandler(this->ProcessButton_Click);
        // 
        // progressBar1
        // 
        this->progressBar1->Location = new System::Drawing::Point(12, 182);
        this->progressBar1->Name = "progressBar1";
        this->progressBar1->Size = new System::Drawing::Size(372, 16);
        this->progressBar1->TabIndex = 12;
        // 
        // ActionLabel
        // 
        this->ActionLabel->AutoSize = true;
        this->ActionLabel->Location = new System::Drawing::Point(59, 166);
        this->ActionLabel->Name = "ActionLabel";
        this->ActionLabel->Size = new System::Drawing::Size(24, 13);
        this->ActionLabel->TabIndex = 11;
        this->ActionLabel->Text = "Idle";
        // 
        // label5
        // 
        this->label5->AutoSize = true;
        this->label5->Location = new System::Drawing::Point(13, 166);
        this->label5->Name = "label5";
        this->label5->Size = new System::Drawing::Size(40, 13);
        this->label5->TabIndex = 10;
        this->label5->Text = "Action:";
        // 
        // progressBar2
        // 
        this->progressBar2->Location = new System::Drawing::Point(12, 251);
        this->progressBar2->Name = "progressBar2";
        this->progressBar2->Size = new System::Drawing::Size(372, 10);
        this->progressBar2->TabIndex = 13;
        // 
        // SpeedLabel
        // 
        this->SpeedLabel->AutoSize = true;
        this->SpeedLabel->Location = new System::Drawing::Point(59, 235);
        this->SpeedLabel->Name = "SpeedLabel";
        this->SpeedLabel->Size = new System::Drawing::Size(24, 13);
        this->SpeedLabel->TabIndex = 15;
        this->SpeedLabel->Text = "Idle";
        // 
        // label7
        // 
        this->label7->AutoSize = true;
        this->label7->Location = new System::Drawing::Point(12, 235);
        this->label7->Name = "label7";
        this->label7->Size = new System::Drawing::Size(41, 13);
        this->label7->TabIndex = 14;
        this->label7->Text = "Speed:";
        // 
        // FileLabel
        // 
        this->FileLabel->AutoSize = true;
        this->FileLabel->Location = new System::Drawing::Point(59, 209);
        this->FileLabel->Name = "FileLabel";
        this->FileLabel->Size = new System::Drawing::Size(24, 13);
        this->FileLabel->TabIndex = 17;
        this->FileLabel->Text = "Idle";
        // 
        // label8
        // 
        this->label8->AutoSize = true;
        this->label8->Location = new System::Drawing::Point(27, 209);
        this->label8->Name = "label8";
        this->label8->Size = new System::Drawing::Size(26, 13);
        this->label8->TabIndex = 16;
        this->label8->Text = "File:";
        // 
        // SizeLabel
        // 
        this->SizeLabel->AutoSize = true;
        this->SizeLabel->Location = new System::Drawing::Point(59, 222);
        this->SizeLabel->Name = "SizeLabel";
        this->SizeLabel->Size = new System::Drawing::Size(24, 13);
        this->SizeLabel->TabIndex = 19;
        this->SizeLabel->Text = "Idle";
        // 
        // label10
        // 
        this->label10->AutoSize = true;
        this->label10->Location = new System::Drawing::Point(23, 222);
        this->label10->Name = "label10";
        this->label10->Size = new System::Drawing::Size(30, 13);
        this->label10->TabIndex = 18;
        this->label10->Text = "Size:";
        // 
        // ListButton
        // 
        this->ListButton->Location = new System::Drawing::Point(309, 139);
        this->ListButton->Name = "ListButton";
        this->ListButton->Size = new System::Drawing::Size(75, 23);
        this->ListButton->TabIndex = 20;
        this->ListButton->Text = "Create List";
        this->ListButton->UseVisualStyleBackColor = true;
        this->ListButton->Click += new System::EventHandler(this->ListButton_Click);
        // 
        // SourceLinkLabel
        // 
        this->SourceLinkLabel->AutoSize = true;
        this->SourceLinkLabel->Location = new System::Drawing::Point(267, 266);
        this->SourceLinkLabel->Name = "SourceLinkLabel";
        this->SourceLinkLabel->Size = new System::Drawing::Size(117, 13);
        this->SourceLinkLabel->TabIndex = 21;
        this->SourceLinkLabel->TabStop = true;
        this->SourceLinkLabel->Text = "Created by Jamie/Hello";
        this->SourceLinkLabel->LinkClicked += new System::Windows::Forms::LinkLabelLinkClickedEventHandler(this->SourceLinkLabel_LinkClicked);
        // 
        // AllowCleanCheckBox
        // 
        this->AllowCleanCheckBox->AutoSize = true;
        this->AllowCleanCheckBox->Location = new System::Drawing::Point(99, 116);
        this->AllowCleanCheckBox->Name = "AllowCleanCheckBox";
        this->AllowCleanCheckBox->Size = new System::Drawing::Size(98, 17);
        this->AllowCleanCheckBox->TabIndex = 22;
        this->AllowCleanCheckBox->Text = "Allow Clean Up";
        this->AllowCleanCheckBox->UseVisualStyleBackColor = true;
        // 
        // DownloadExistingButton
        // 
        this->DownloadExistingButton->Location = new System::Drawing::Point(169, 139);
        this->DownloadExistingButton->Name = "DownloadExistingButton";
        this->DownloadExistingButton->Size = new System::Drawing::Size(134, 23);
        this->DownloadExistingButton->TabIndex = 23;
        this->DownloadExistingButton->Text = "Download Existing Data";
        this->DownloadExistingButton->UseVisualStyleBackColor = true;
        this->DownloadExistingButton->Click += new System::EventHandler(this->DownloadExistingButton_Click);
        // 
        // btnFixGZ
        // 
        this->btnFixGZ->Location = new System::Drawing::Point(93, 139);
        this->btnFixGZ->Name = "btnFixGZ";
        this->btnFixGZ->Size = new System::Drawing::Size(75, 23);
        this->btnFixGZ->TabIndex = 24;
        this->btnFixGZ->Text = "Fix *.gz";
        this->btnFixGZ->UseVisualStyleBackColor = true;
        this->btnFixGZ->Click += new System::EventHandler(this->btnFixGZ_Click);
        // 
        // AMain
        // 
        this->AutoScaleDimensions = new System::Drawing::SizeF(6.0F, 13.0F);
        this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
        this->ClientSize = new System::Drawing::Size(392, 292);
        this->Controls->Add(this->btnFixGZ);
        this->Controls->Add(this->DownloadExistingButton);
        this->Controls->Add(this->AllowCleanCheckBox);
        this->Controls->Add(this->SourceLinkLabel);
        this->Controls->Add(this->ListButton);
        this->Controls->Add(this->SizeLabel);
        this->Controls->Add(this->label10);
        this->Controls->Add(this->FileLabel);
        this->Controls->Add(this->label8);
        this->Controls->Add(this->SpeedLabel);
        this->Controls->Add(this->label7);
        this->Controls->Add(this->progressBar2);
        this->Controls->Add(this->progressBar1);
        this->Controls->Add(this->ActionLabel);
        this->Controls->Add(this->label5);
        this->Controls->Add(this->ProcessButton);
        this->Controls->Add(this->label4);
        this->Controls->Add(this->PasswordTextBox);
        this->Controls->Add(this->label3);
        this->Controls->Add(this->LoginTextBox);
        this->Controls->Add(this->label2);
        this->Controls->Add(this->HostTextBox);
        this->Controls->Add(this->label1);
        this->Controls->Add(this->ClientTextBox);
        this->Name = "AMain";
        this->Text = "Auto Patcher Admin";
        this->Load += new System::EventHandler(this->AMain_Load);
        this->ResumeLayout(false);
        this->PerformLayout();

    }
}
